<template>
  <div id="app">
    <navigation>
      <router-view></router-view>
    </navigation>
    <router-view name="mainconten"></router-view>
    <footer-link></footer-link>
  </div>
</template>

<script>
import navTop from "@/components/navTop"
import footerLink from "@/components/footer_link"
import { mapState, mapMutations } from 'Vuex'
import { getuserinfo} from "api/auto"
export default {
  name: 'App',
  components:{
    navTop,
    footerLink
  },
  watch: {
    $route() {
      
      (function smoothscroll(){
          var currentScroll = document.documentElement.scrollTop || document.body.scrollTop;
          if (currentScroll > 0) {
              window.requestAnimationFrame(smoothscroll);
              window.scrollTo (0,currentScroll - (currentScroll/5));
          }
      })();
      document.title = this.$route.name;
      this._getUserinfo();
    }
  },
  data(){
    return {
      nidma:"fnidf"
    }
  },
  methods:{
     ...mapMutations([ 'saveUserInfo' ] ),
      _getUserinfo(){
            getuserinfo().then(res=>{
                if(res.code==0){
                    this.saveUserInfo(res.data[0]);
                    (function smoothscroll(){
                        var currentScroll = document.documentElement.scrollTop || document.body.scrollTop;
                        if (currentScroll > 0) {
                            window.requestAnimationFrame(smoothscroll);
                            window.scrollTo (0,currentScroll - (currentScroll/5));
                        }
                    })();
                }
            });
        },
  }

}
</script>

<style scoped>
  #app{
    width: 100%;
    overflow: hidden;
  }
</style>
